package com.sjm.demo.utils;

import lombok.Data;

/**
 * @author sjm
 * @create 2021-03-12 10:42
 */
@Data
public class ResultData {

    private int code;
    private Object data;
    private String message;

    public ResultData() {
    }

    private ResultData(int code, Object data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }

    public ResultData success(String message){
        return new ResultData(200,null,message);
    }

    public ResultData success(Object data){
        return new ResultData(200,data,null);
    }

    public ResultData success(Object data, String message){
        return new ResultData(200,data,message);
    }

    public ResultData success(int code, Object data, String message){
        return new ResultData(code,data,message);
    }

    public ResultData error(String message){
        return new ResultData(500,null,message);
    }

    public ResultData error(Object data){
        return new ResultData(500,data,null);
    }

    public ResultData error(Object data, String message){
        return new ResultData(500,data,message);
    }

    public ResultData error(int code, Object data, String message){
        return new ResultData(code,data,message);
    }
}
